package cn.edu.gdpt.xxgc.mobile0123456789hwh0328;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

public class LightActivity extends AppCompatActivity {

    private Button btnLightOn;
    private Button btnLightOff;
    private ImageView ivLightLight;

    // 控件初始化
//    按钮点击事件
//    处理单元中写逻辑业务代码
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_light);
        initView();
        ivLightLight.setImageResource(R.drawable.ic_launcher_background);

        btnLightOn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ivLightLight.setImageResource(R.drawable.light_on);
            }
        });
        btnLightOff.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ivLightLight.setImageResource(R.drawable.light_off);
            }
        });
    }
    private void initView() {
        ivLightLight = (ImageView) findViewById(R.id.ivLightLight);
        btnLightOn = (Button) findViewById(R.id.btnLightOn);
        btnLightOff = (Button) findViewById(R.id.btnLightOff);
    }
}